<!DOCTYPE html>
<html>

<head>
    <base href="{#location.origin#}/res/smartadmin-402/" />
    <meta charset="utf-8">
    <title>
        {#data.project_app_id ? '编辑' : '新建'#}应用 - {#uim.config.app_name#}
    </title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, minimal-ui">
    <!-- Call App Mode on ios devices -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- Remove Tap Highlight on Windows Phone IE -->
    <meta name="msapplication-tap-highlight" content="no">
    <!-- base css -->
    <link rel="stylesheet" media="screen, print" href="css/vendors.bundle.css">
    <link rel="stylesheet" media="screen, print" href="css/app.bundle.css">
    <!-- Optional: page related CSS-->
    <link rel="stylesheet" media="screen, print" href="css/formplugins/select2/select2.bundle.css">
</head>

<body>
    {#include template="include/page-settings"/#}
    <!-- BEGIN Page Wrapper -->
    <div class="page-wrapper alt">
        <!-- BEGIN Page Content -->
        <!-- the #js-page-content id is needed for some plugins to initialize -->
        <main id="js-page-content" role="main" class="page-content">
            <ol class="breadcrumb page-breadcrumb">
                <li class="breadcrumb-item">应用管理</li>
                <li class="breadcrumb-item active">{#data.project_app_id ? '编辑' : '新建'#}应用</li>
            </ol>

            <div class="row">
                <div class="col-xl-12">
                    <div id="panel-6" class="panel">
                        <div class="panel-hdr">
                            <h2>
                                新建应用
                            </h2>
                        </div>
                        <div class="panel-container show">
                            <form class="needs-validation" novalidate autocomplete="off">
                                <input type="hidden" name="project_app_id" value="{#data.project_app_id || ''#}">
                                <div class="panel-content">
                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            所属项目</label>
                                        <div class="col-12 col-lg-6 ">
                                            <select class="form-control" name="project_id"
                                                uim-api="project.list,project_list,project_id,project_name"
                                                uim-api-data="{limit:50}" uim-value="{#data.project_id || ''#}"
                                                required>
                                                <!-- <option value="0">请选择所属项目</option> -->
                                            </select>
                                            <div class="invalid-tooltip">
                                                请选择所属项目！
                                            </div>

                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            应用名称</label>
                                        <div class="col-12 col-lg-6 ">
                                            <input type="text" class="form-control" name="project_app_name"
                                                value="{#data.project_app_name || ''#}" placeholder="应用名称" required>
                                            <div class="invalid-tooltip">
                                                应用名称不能为空！
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right">
                                            备注/描述</label>
                                        <div class="col-12 col-lg-6">
                                            <textarea name="description" placeholder="请输入详细内容"
                                                class="form-control input-md" rows="8" maxlength="200"
                                                required></textarea>
                                            <div class="invalid-tooltip">
                                                描述内容不能为空！
                                            </div>

                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-form-label col-12 col-lg-3 form-label text-lg-right"></label>
                                        <div class="col-12 col-lg-6">
                                            <button class="btn btn-primary">提交</button>
                                        </div>
                                    </div>

                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </main>
        <!-- END Page Content -->
    </div>
    <!-- END Page Wrapper -->
    <!-- LOST END Quick Menu -->
    {#include template="include/color-profile"/#}
    <script src="js/vendors.bundle.js"></script>
    <script src="js/app.bundle.js"></script>
    <script src="js/formplugins/select2/select2.bundle.js"></script>


    {#'<script>var description = '+ JSON.stringify(data.description||"") +';</script>'#}

    <script>

        $('textarea').val(description);
        description = null;// 内容字段可能比较大，此处从内存中清除该变量

        $(function () {

            $('select').on('uim-render', function (event, param) {
                $(this).select2({
                    minimumResultsForSearch: Infinity,
                    placeholder: "请选择"
                });
                event.stopPropagation();
            });
            $('form').on('uim-submit', function (event, param) {
                // param.data.content = container.getContent();
                param.data.project_id *= 1;
                uim.api.emit({
                    code: "{#data.project_app_id ? 'project.app.edit' : 'project.app.create'#}",
                    data: param.data,
                    success: function (data) {
                        parent.toastr.success('创建成功')
                        initApp.playSound('media/sound', 'voice_on')
                        setTimeout(function () {
                            uim.view('app/list', {}, window);
                        }, 1000);
                    },
                    error: function (err) {

                    }
                });
            });
        })


    </script>

    {#include template="include/common"/#}


</body>

</html>